package model;

/***
 * Class which represents an attribute of a class with a name and an access.
 * @author Federico
 *
 */
public class Attribute {
	
	private String name;
	//0 = private, 1 = public, 3 = parameter
	private int access;
	
	/**
	 * Constructor of attributes
	 * @param n the name for the attrbite
	 * @param a if the value is 0 de access is false(private) else true(public)
	 */
	public Attribute(String n, int a){
		name = n;
		if(a >= 0 && a <= 3)
			access = a;
		else access = 3;
	}
	
	public Attribute(String n){
		name = n;
		access = 3;
	}
	
	public boolean isPublic(){
		return access==1;
	}
	
	public boolean isPrivate(){
		return access==0;
	}
	
	public boolean isParameter(){
		return access==3;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String toString(){
		String acc;
		if(isPublic())acc="+";
		else acc="-";
		return acc+name;
	}
}
